Welcome To
Built In
Functions
In List

Built In Functions In lists Python

The Built in function in a lists means that functions are already defined or predefined functions that helps to perform the various operations in the python list . the built in functions provide the rich set of function that perform a more operations in the python code . some most common built in function in the below

Functions

  1. len()
  2. sum()
  3. min()
  4. max()
  5. any()
  6. all()
  7. sorted()
  8. list()

Len() function

Len() function in the list is used to checks the length of the list elements . Example in the below

Example

list1=[10,20,30,"hello","coder"]
print(len(list1))

Output

5

sum() function

The sum() function is used to perform the addition operations . and find the sum of the all the elements in the list . and the sum() function performs only can list having a number data type . Example in the below

Example

list1=[10,20,30 ]
print(sum(list1))

Output

60

min() function

The min() function performs a some operation if the list can having only number data type . it is used to find the minimum value of element in the list. Example in the below

Example

list1=[10,20,30. ]
print(min(list1))

Output

10

max() function

The max() function in the list can performs the operation when the list can having the number data type only. it is used to find the maximum value of element in the list. Example in the below

Example

list1=[10,20,30. ]
print(max(list1))

output

30.0

any() function

The any() function is returns the true when the list can having at least one element. the list is null or none then returns the false. example in the below

Example

list1=[10,20,30]
print(any(list1))

Output

True

All() function

The all Function is performs a operation in the list . it returns the true when the list can having the more then one data element or multiple data types . the list having the a single data element then returns a false. / if the list can having the none type then also it returns false Example in the below

Example

list1=[10,20,30,None]
print(all(list1))

output

False

Sorted() function

The sorted() function is used to sort the list element in a ascending or descending order . if the list having number type then the sorted() function is sort the list element base on the value . if the list can having a string type then it sort the based on alphabetical order . Example in the below

Example

list1=[30,10,3,5,6,]#number type
print(sorted(list1))

Output

[3, 5, 6, 10, 30]

list1=["a", "d","c", "e", "z"]#string, type print(sorted(list1))

['a', 'c', 'd', 'e', 'z']

list() function

The list() function is used to convert the one data type to another data type . Example in the below

Example

list1=("a", "d","c", "e", "z")#tuple, type
print(list(list1))
print(type(list1))

output

['a', 'd', 'c', 'e', 'z']
class 'list'